import * as echarts from 'echarts'

const getBarChart = (data: any) => {
  let { seriesData, xAxisData, color } = data
  return {
    grid: {
      left: 30,
      right: 20,
      top: 30, //拉伸距离顶部高度
      bottom: 0, //拉伸距离底部高度
      containLabel: true
    },
    xAxis: {
      type: 'category',
      boundaryGap: true, // 数值居中还是居边
      data: xAxisData,
      axisLine: {
        //轴线
        show: true
      },
      splitLine: {
        //分割线
        show: false
      }
    },
    yAxis: {
      type: 'value',
      axisTick: {
        // 刻度线
        show: false
      },
      axisLine: {
        //轴线
        show: false
      },
      splitLine: {
        show: true,
        lineStyle: {
          type: 'dashed'
        }
      }
    },
    series: [
      {
        barWidth: 16, //柱图宽度
        data: seriesData,
        type: 'bar',
        label: {
          //数值样式
          show: true,
          position: 'top', //柱形右边
          color: 'inherit'
        },
        itemStyle: {
          //这里设置柱形图圆角 [左上角，右上角，右下角，左下角]
          borderRadius: [2, 2, 0, 0],
          color: color
        }
      }
    ]
  } as echarts.EChartsOption
}
export { getBarChart }
